package org.common.akka;

import akka.actor.typed.ActorSystem;
import akka.actor.typed.ActorRef;
import akka.actor.typed.Behavior;
import akka.actor.typed.Props;
import org.common.akka.actor.RootActor;
import org.common.akka.message.BaseMsg;

final public class AkkaContext {

    private static ActorSystem<BaseMsg> ACTOR_SYSTEM;

    public static void initActorSystem() {
        ACTOR_SYSTEM = ActorSystem.create(RootActor.create(), "ActorSystem");
    }

    public static ActorRef<BaseMsg> createActor(Behavior<BaseMsg> behavior, String name) {
        return ACTOR_SYSTEM.systemActorOf(behavior, name, Props.empty());
    }
}
